package com.ruoyi.worker.domain.workAttendance;

import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.SecurityUtils;
import lombok.Data;
import lombok.ToString;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.math.BigDecimal;
import java.util.List;

/**
 * @ClassName RzAttendanceSalarySum
 * @Description 工资汇算总表
 * @Author leizhang
 * Date 2021/11/28 11:32 下午
 * @Version 1.0
 **/
@Data
public class RzAttendanceSalarySum extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /** 考勤工资汇总表 */
    private int id;

    /** 班组id */
    @Excel(name = "班组id")
    private Integer deptId;

    /** 班组名称 */
    @Excel(name = "班组名称")
    private String deptName;

    /** 工资单月份 考勤月份 */
    @Excel(name = "工资单月份 考勤月份")
    private String workTime;

    /** 应发工资总额 */
    @Excel(name = "应发工资总额")
    private BigDecimal salarySum = new BigDecimal(0);

    /** 实际发放总额 */
    @Excel(name = "实际发放总额")
    private BigDecimal actualSalarySum = new BigDecimal(0);

    private List<AttendanceSalary> attendanceSalary;

    public RzAttendanceSalarySum() {
    }

    public RzAttendanceSalarySum(Integer deptId ,String deptName, List<AttendanceSalary> attendanceSalary, String workTime) {
        this.deptId  = deptId;
        this.deptName = deptName;
        this.workTime = workTime;
       attendanceSalary.forEach(salary ->{
           actualSalarySum = actualSalarySum.add(salary.getPaidWages());
           salarySum = salarySum.add(salary.getPayable());
       });
       setCreateBy(SecurityUtils.getUsername());
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("deptId", getDeptId())
                .append("deptName", getDeptName())
                .append("workTime", getWorkTime())
                .append("salarySum", getSalarySum())
                .append("actualSalarySum", getActualSalarySum())
                .append("createBy", getCreateBy())
                .toString();
    }
}
